package chapter3.homework;

import java.io.*;

/**
 * @Project ：learn_java
 * @File ：Q3.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/3/1 20:32
 * @Description ：输出指定pdf，即复制到当前目录下
 */

public class Q3 {
    public static void main(String[] args) throws IOException {
        String srcPath = "E:\\BaiduNetdiskDownload\\何学长java\\03第三章 IO流技术\\笔记及课后作业\\IO流技术_第二章.pdf";
        String destPath = "IOTestOutputFiles\\IO流技术_第二章.pdf";

        try (
            FileInputStream fis = new FileInputStream(srcPath);
            BufferedInputStream bis = new BufferedInputStream(fis);
            FileOutputStream fos = new FileOutputStream(destPath);
            BufferedOutputStream bos = new BufferedOutputStream(fos)
                ) {
            byte[] buffer = new byte[1024];
            int byteRead;
            while ((byteRead = bis.read(buffer)) != -1) {
                bos.write(buffer, 0, byteRead);
            }
            bos.flush();
            System.out.println("文件复制成功");
        } catch (IOException e) {
            System.err.println("文件复制过程中出现错误：" + e.getMessage());
        }
    }
}
